<?php
/**
 * Description of Curl
 *
 * @author wzhzhang
 */
class Helper_Curl 
{
    //put your code here
    public static function curl($url, $get = array(), $post = array()) 
    {
        if ($get)
        {
        $tmp = array();
            foreach ( $get as $key => $value )
            {
                $tmp[] = "{$key}={$value}";
            }

            $url .= "?" . implode( "&" , $tmp );
        }
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        if ($post) {
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
        }

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_USERAGENT, 'PHP CURL Client');
        $result = curl_exec($ch);
        $errno = curl_errno($ch);
        if ($errno) {
            throw new AppException( 7000 );
        }

        curl_close($ch);
        return $result;
    }
}